function getMenuRouter(pathname = "", menuDataList = []) {
  // const { locations: { pathname = '' }, menuDataList } = this.props || {};
  let menuRouterItem = {};
  if (this.oldPathname === pathname) return this.menuRouterItem;
  this.oldPathname = pathname;

  const newArr = menuDataList.filter((ele) => ele.link === pathname);
  if (newArr && newArr.length > 0) {
    menuRouterItem = { ...newArr[0] };
  }
  this.menuRouterItem = menuRouterItem;
  return menuRouterItem;
}

function getPageOperate(
  type = "",
  pathname = "",
  menuDataList = [],
  resourceList = [],
) {
  const menuRouterItem = this.getMenuRouter(pathname, menuDataList);
  const { pageOperate = {} } = menuRouterItem || {};
  const operateId = pageOperate[type];
  if (resourceList.some((ele) => ele === operateId)) {
    return true;
  }
  // 当前版本不对操作进行权限控制，若需要对操作进行权限控制，改为 false
  return true;
}

export { getMenuRouter, getPageOperate };
